<script type="text/javascript" src="java/formval.js"></script>
<script type="text/javascript">
function validateOnSubmit(formElem) {
	var elem;
	var errs=0;
	if (!validatePresent(formElem.GalerieName,  'GalerieNameError', true))  		errs = 1;
	
	if (errs==0){
		formElem.submit();
	}
};
</script>
<script type="text/javascript">
function  deleteZimmer(id , name){
	if (confirm("<?PHP LangText('DeleteMas'); ?>")) {//if yes
	   window.location =document.URL+'&GalerieID='+id;
	}
}
</script>
<?php
if (!empty ($_SESSION["CMS_User"]["ID"])) {
	if (!empty ($_GET['GalerieID'])) {
		$sql = "DELETE  FROM galerie WHERE UserID={$_SESSION["CMS_User"]["ID"]} and ID = {$_GET['GalerieID']} ";
		mysql_query($sql, $_db_link);
	}
	if (!empty ($_POST["GalerieName"])) {
		$sql = "insert into 
				     galerie (Name,UserID) 
					values('" . $_POST["GalerieName"] . "'
					,'" . $_SESSION["CMS_User"]["ID"] . "')";
		$_rd = mysql_query($sql, $_db_link);
	}
	$sql = "select * From galerie WHERE UserID={$_SESSION["CMS_User"]["ID"]}";
	$_rd = mysql_query($sql, $_db_link);
	$str = "";
	if ($_rd) {
		$sw = "row1";
		$str = "<div class='FirmaView'><table class='FirmaList'>
							<tr class='$sw'>
							<td><b>" . LangTextOut("ID") . "</b></td>
							<td><b>" . LangTextOut("Name") . "</b></td>" .
		"</tr>";
		while ($daten = mysql_fetch_array($_rd, MYSQL_ASSOC)) {
			if ($sw == "row1") {
				$sw = "row2";
			} else {
				$sw = "row1";
			}
			$str = $str . "<tr class='$sw'>
											<td>" . $daten["ID"] . "</td>
											<td>" . $daten["Name"] . "</td>" .
			"<td><a href='index.php?tag=$tagID&page=GalerieEdit&MoudeTagID=$MoudeTagID&GalerieID=" . $daten["ID"] . "'>" .
			LangTextOut("Detail") . "</a></td>" .
			"<td><a  href=\"javascript:deleteZimmer('" . $daten["ID"] . "','" . $daten["Name"] . "');\"  >" . LangTextOut("Delete") . "</a>" .
			"</td>" .
			"</tr>";
		}
		$str = $str . "</table></div>";
	}
	$str = $str . "<hr>";
	echo $str;
}
?>
	<div style="width:100%;background-color:#F1EEF3;margin:0px"> 
	<table class="tableEdit">
	<td class="lableEdit"><?PHP  LangText("GalerieName");?>:*</td>
	<td class="inputEdit"><input type="text" name="GalerieName" id="GalerieName"  onchange="validatePresent(this, 'GalerieNameError');" value='<?PHP echo $daten["AusflugName"]; ?>' /></td>
	<td class="validateEdit"><input type="label"  DISABLED  id="GalerieNameError" value='<?PHP LangText("GalerieNameError");?>' /></td>
	</tr>
		
	<tr>
	<td class="lableEdit"></td>
	<td class="inputEdit"><input type="button"  onclick="validateOnSubmit(this.form);" class="BootenLink" value='<?PHP if($AusflugID!=NULL && $AusflugID != 0 ){LangText("Bearbeiten");}else{ LangText("Himzufugen");}?>' />
	</td>
	<td class="validateEdit"></td>
	</tr>
	</table>
	</div>
